<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ASIMS</title>
<link href="../CSS/style.css" rel="stylesheet" type="text/css" />
<script language="JavaScript">
function clickalert(j){
var obj=document.getElementsByName('news.newscategory');
//var i;
  for( var i = 0; i < obj.length; i++ )
  {
	if ( i!=j){
		obj[i].checked=false;
	}
   }
 
}
function deleteFile(j){
	if(window.confirm('确定要删除该附件吗？'))
	{
		var obj=document.getElementsByTagName('span');
		for(var i=0;i<obj.length;i++)
		{
		   
			if(obj[i].id==="filespan"+j){
			 //alert("s"+obj[i].innerHTML+"s");
			  obj[i].innerHTML="附件"+j;
			}
		}
        
	}
	//alert("finish");
}
function beforesubmit(){
   // alert("beforesubmit");
	var obj=document.getElementsByTagName('span');
	var fileObj=document.getElementById('hfileName');
	for(var i=0;i<obj.length;i++)
	{
	//alert("beforesubmit for "+obj[i].id);
		if(obj[i].id==="filespan1"){
		  if(obj[i].innerHTML!=="附件1"){
		  if(null!==fileObj.value)
		     fileObj.value+="@";
		   fileObj.value=document.getElementById('filespan1').innerHTML;
		   }
			
		}
		else if(obj[i].id==="filespan2"){
		  if(obj[i].innerHTML!=="附件2"){
		    if(null!==fileObj.value&&""!==fileObj.value)
		     fileObj.value+="@";
		    fileObj.value+=document.getElementById('filespan2').innerHTML;
		  }
		   
		}
		// alert("submit:"+fileObj.value);
	}

}
function upload(){
	var obj=document.getElementsByTagName('span');
	var changed=0;
	for(var i=0;i<obj.length;i++)
	{
		if((obj[i].innerHTML=="附件1"||obj[i].innerHTML=="附件2")&&changed!=1){	
			obj[i].innerHTML=document.getElementById('fileInput').value;
			changed=1;		
		}
	}
	if(changed==0)
		alert("附件已满，请删除后继续操作");
}
function init()
{
//alert("1"+document.getElementById('filespan1').innerHTML+"1");
 if(""==document.getElementById('filespan1').innerHTML||null==document.getElementById('filespan1').innerHTML)
 {
 	document.getElementById('filespan1').innerHTML="附件1";
 }
 //alert("2"+document.getElementById('filespan2').innerHTML+"2");
 if(""==document.getElementById('filespan2').innerHTML||null==document.getElementById('filespan2').innerHTML)
 {
 	document.getElementById('filespan2').innerHTML="附件2";
 }
 var obj=document.getElementsByName('news.newscategory');
 var c=document.getElementById('category').value;
//var i;
  for( var i = 0; i < obj.length; i++ )
  {
  
	if ( obj[i].value==c){
		obj[i].checked=true;
	}
   }
  var filespan=document.getElementsByTagName('span');
  if(null!==document.getElementById('acc1').value)
     document.getElementById('filespan1').innerHTML=document.getElementById('acc1').value;
    if(null!==document.getElementById('acc2').value)
     document.getElementById('filespan2').innerHTML=document.getElementById('acc2').value;
    
}
</script>

</head>

<body onload='init()'>
	<div id="wrap">
		<div id="header">
			<h1 id="sitename"><a href="#">ASIMS</a></h1>
			<div id="nav">
				<div id="titleblock">
					<div id="subject">机场静态信息管理系统</div>
					<div id="spirit"><a href="#"><%= session.getAttribute("username") %>  已登录</a> | <a href ="javascript:window.location.href='queryUserForIndex.action'">个人信息维护</a>| <a href="../login/login.jsp" target="_parent">注销</a></div>
		 		</div>
				<div id="topmenu">
				<ul>
					<li><a href="../login/index.jsp">首页</a></li>
						<li><a href="../rolemanage/user_manag.jsp">用户和角色管理</a></li>
						<li><a href="../airline_manage/airline_manag_InAr.jsp">航班信息管理</a></li>
						<li><a href="../facilities_manag/facilities_manag.jsp">机场设施管理</a></li>
						<li class="active"><a href="../news/news_view_intr.jsp">新闻中心</a></li>
				</ul>
				</div>
			</div>
			<div class="clear"></div>
			<div id="breadcrumb">网站路径：<a href="../login/index.jsp">首页</a> &raquo; <a href="news_view_intr.jsp" class="active">新闻中心</a></div>
		</div>
		
		<div id="content">
			<div id="right">
			   <div class="post">
					<h2><a href="">修改新闻</a></h2>
						<form action="updateNews.action" method="post"
										enctype="multipart/form-data">
							<div class="contactform">
								<p class="first">
								<label for="newstitle">新闻标题：</label>
								<s:textfield name="news.newstitle" value="%{#session.updateNews.newstitle}"></s:textfield>
								</p>
								<p>
								<s:hidden id="category" value="%{#session.updateNews.newscategory}"></s:hidden>
									<label for="newscategory">新闻类别：</label>
									<s:checkbox name="news.newscategory" fieldValue="机场介绍" value="%{#session.updateNews.newscategory}" label="" onClick="clickalert(0);"/>
									机场介绍　
									<s:checkbox name="news.newscategory" fieldValue="航班信息" value="%{#session.updateNews.newscategory}" label="" onClick="clickalert(1);"/>
									航班信息　
									<s:checkbox name="news.newscategory" fieldValue="机场资源" value="%{#session.updateNews.newscategory}" label="" onClick="clickalert(2);"/>
									机场资源　
									<s:checkbox name="news.newscategory" fieldValue="物业设施" value="%{#session.updateNews.newscategory}" label="" onClick="clickalert(3);"/>
									物业设施	
								</p>
								<p>
									<label for="newscontent">新闻正文：</label>
									<s:textarea name="news.newscontent" value="%{#session.updateNews.newscontent}" cols="400" rows="10" cssStyle="height:150px;width:400px" ></s:textarea>
									<s:hidden name="news.newsId" value="%{#session.updateNews.newsId}"></s:hidden>
								</p>
							</div>
						<table class="specialtable" cellspacing="0" cellpadding="0">
							<tr>
							  <th scope="col">附件</th>
							  <th scope="col">操作</th>
							</tr>
							<tr>
							  <td><a href=""><span id="filespan1" class="red" >附件1</span></a></td>
							  <td>
							  <s:hidden id="acc1" value="%{#session.accessary1}"></s:hidden>
									<a> 
									<span class="black" onClick="deleteFile(1)">删除</span>
									</a>
								</td>
							</tr>
							<tr>
							  <td><span id="filespan2" class="red">附件2</span></a></td>
							  <td>
									<a>
									<s:hidden name="acc2" value="%{#session.accessary2}"></s:hidden>
									<span class="black" onClick="deleteFile(2)">删除</span>
									</a>
							</tr>
							<tr>
							  <td>上传新附件：</td>
							  <td><span class="fileInput"><input type="file" id="fileInput" name="fileInput" onChange="upload()"></span></td>
							<s:hidden id="hfileName" name="fileInput" value=""></s:hidden>
							</tr>
					 	 </table>
						<div class="buttons">
							<div class="butarea2"></div>
							<button type="submit" name="add" onClick="beforesubmit()">
								<img src="../images/import16.png" alt=""/> 
								保存
							</button>
							<button type="reset" name="cancel" onClick="javascript:window.location.href='news_view_intr.jsp'">
								<img src="../images/cancel16.png" alt=""/> 
								取消
							</button>
						</div>
					</form>
				</div>
			</div>
			
			<div id="sidebar">
				<div id="sidebartop"></div>
					 <h2>新闻浏览</h2>
						<ul>
						  <li class="active"><a href="news_view_intr.jsp">机场介绍</a></li>
						  <li><a href="news_view_airl.jsp">航班信息</a></li>
						  <li><a href="news_view_faci.jsp">机场资源</a></li>
						  <li><a href="news_view_agen.jsp">物业资源</a></li>
						</ul>
					<h2>新闻发布</h2>
						<ul>
						  <li><a href="news_publish.jsp">发布新闻</a></li>
						</ul>
					<h2>新闻订阅</h2>
						<ul>
						  <li><a href="news_order.jsp">订阅新闻</a></li>
						</ul>
			</div>
			<div class="clear"></div>
			<div id="bottom">
				<p><img src="../images/copyright.jpg" /></p>
				<p><a href="">隐私权</a> | <a href="">&copy;版权</a> | <a href="">法律声明</a> | <a href="">电子邮件：admin@163.com</a>
			</div>
		</div>
		
		<div id="footer">
			<div id="credits">
				ASIMS Power by IBM
			</div>
		</div>
	</div>

</body>
</html>

